﻿Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.ServiceModel.Description
Imports System.Runtime.Serialization


Namespace WebService
    <DataContract()> _
    Public Class ServiceInfo
        Private service_api_ver As String = "0.9.1"
        Private start_time As Date
        Private service_status As ServiceStatus = New ServiceStatus()

        ' Apply the DataMemberAttribute to the property.

        Public Sub New()
            start_time = Date.Now
        End Sub

        <DataMember()> _
        Public Property UpTime() As Long
            Get
                Return DateDiff(DateInterval.Minute, start_time, Date.Now)
            End Get
            Private Set(ByVal value As Long)
                ' Do Nothing
            End Set
        End Property

        <DataMember()> _
        Public Property ServiceAPIVersion() As String
            Get
                Return service_api_ver
            End Get
            Private Set(ByVal value As String)
                ' Do Nothing
            End Set
        End Property

        <DataMember()> _
        Public Property Status() As ServiceStatus
            Get
                Return service_status
            End Get
            Set(ByVal value As ServiceStatus)
                'Do Nothing
            End Set
        End Property

        Overrides Function ToString() As String
            Dim rv As String = "(State=[" + Me.Status.ToString() + "]" +
                               ", UpTime=" + Me.UpTime + " (Mins)" +
                               ", ServiceAPI=" + Me.ServiceAPIVersion + ")"
            Return rv
        End Function

    End Class
End Namespace
